/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once
#include <stack>
#include <map>
#include "IProcess.h"
#include "render/IGameStateView.h"


/**
==========================
Handle the Game Stack, pop and push
states
==========================
*/
class GameManager : public IProcess
{
public:
    GameManager(void);
    /** Initialize the game subsystem */
    int Init();
    /** Update the current Game State */
	void Update(float  dt);
    /** Close off the subsystem */
	void Shutdown();

    /** Add a gamestate, and a game view */
    void AddState(  IGameState* state, IGameStateView* stateView);
    /** Remove a State */
	void RemoveState(  IGameState* state );

    /** Get the current State */
	IGameState* GetCurrentState();
    /** set the current State */
    void SetState(const std::string stateName, bool drawOldView=false );
    /** Load another State */
    void PushState(const std::string stateName, bool drawOldView=false );
    /** Load the Previous State */
    void PopState(bool keepOldActive=false);

    /** Get User input */
	void GetInput();
   

private:
    // TODO: Make this a Stack, not a hashmap
    typedef std::map< std::string, IGameState* > type_GameStates;
    type_GameStates      gameStates;

    typedef std::stack< std::string > type_GameStack;
    type_GameStack       gameStack;

    // current state id
    std::string m_current;
    // previous state id
    std::string m_prevState;

    // current state
    IGameState*      m_currentState;
    // id for states
    static int m_idcounter;

public:
    virtual ~GameManager(void);
};
